/*
 * test-ringbuf.c - unit tests for C ring buffer implementation.
 *
 * Written in 2011 by Drew Hess <dhess-src@bothan.net>.
 *
 * To the extent possible under law, the author(s) have dedicated all
 * copyright and related and neighboring rights to this software to
 * the public domain worldwide. This software is distributed without
 * any warranty.
 *
 * You should have received a copy of the CC0 Public Domain Dedication
 * along with this software. If not, see
 * <http://creativecommons.org/publicdomain/zero/1.0/>.
 */

#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <signal.h>
#include <assert.h>
#include "ringbuf.h"
int main(){

ringbuf_t * r =  ringbuf_new(7);
char buf[3] = {'a','b','c'};
ringbuf_memcpy_into(r, buf, sizeof(buf));
printf("w %d\n", ringbuf_bytes_used(r));
printf("f %d\n", ringbuf_bytes_free(r));

void *rbuf = malloc(1);
while (1){
    void *p = ringbuf_memcpy_from(r, rbuf, 1);
    if (p != NULL)
        printf("read %c\n", *(char *)rbuf);
    else {
        printf("no data\n");
        break;
     }
}
}

